//
//  UILabel+HSQCustLabel.m
//  LiTianDecoration
//
//  Created by administrator on 2018/7/31.
//  Copyright © 2018年 administrator. All rights reserved.
//

#import "UILabel+HSQCustLabel.h"

@implementation UILabel (HSQCustLabel)

/**
 * @brief 设置带有行间距的Label
 */
- (void)SetTheLabelWithRowSpacing:(CGFloat)Spacing string:(NSString *)text{
    
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];
    
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    
    [paragraphStyle setLineSpacing:Spacing];
    
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [text length])];
    
    [self setAttributedText:attributedString];
    
//    [self sizeToFit];
}

/**
 * @brief 设置带有行间距的Label
 */
- (void)SetTheLabelWithRowSpacing:(CGFloat)Spacing{
    
    NSString *text = self.text;
    
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];
    
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    
    [paragraphStyle setLineSpacing:Spacing];
    
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [text length])];
    
    [self setAttributedText:attributedString];
    
    [self sizeToFit];
    
}

@end
